package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.Attribute;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QAttribute is a DSLite query type for Attribute
 * @see Attribute
 */
public class QAttribute extends QEntityBase<Attribute> {

    public static final QAttribute $ = new QAttribute("ATTRIBUTE");

    public final StringColumn name = varchar("NAME", 32).field("name").notNull().build();

    public final NumberColumn<Integer> seqOrder = integer("SEQ_ORDER").field("seqOrder").notNull().build();

    public final StringColumn attributeGroupId = varchar("ATTRIBUTE_GROUP_ID", 22).field("attributeGroupId").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndexA = index("CONSTRAINT_INDEX_A").column(attributeGroupId).build();

        public final Index primaryKeyA = index("PRIMARY_KEY_A").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintA6 = foreignKey(attributeGroupId, "ATTRIBUTE_GROUP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QAttribute(String tableName) {
        super(Attribute.class, tableName);
    }

    @Override
    public Attribute newEntity() {
        return new Attribute();
    }

    @Override
    public Object getFieldValue(Attribute entity, String fieldName) {
        switch (fieldName) {
            case "name":
                return entity.getName();
            case "seqOrder":
                return entity.getSeqOrder();
            case "attributeGroupId":
                return entity.getAttributeGroupId();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(Attribute entity, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                entity.setName((java.lang.String) value);
                break;
            case "seqOrder":
                entity.setSeqOrder((java.lang.Integer) value);
                break;
            case "attributeGroupId":
                entity.setAttributeGroupId((java.lang.String) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

